package com.qen.truelicense.license.ftp;

import com.qen.truelicense.license.CipherParam;
import com.qen.truelicense.license.DefaultLicenseParam;
import com.qen.truelicense.license.KeyStoreParam;
import com.qen.truelicense.license.LicenseContent;
import com.qen.truelicense.util.ObfuscatedString;
import lombok.Getter;

import java.util.prefs.Preferences;

/**
 * This is a convenience class implementing some methods of the
 * {@link LicenseParam} interface.
 *
 * @author licz
 * @version 1.0.0
 */
@Getter
public abstract class AbstractLicenseParam extends DefaultLicenseParam implements LicenseParam {

    private static final String LICENSE_CONTENT_INFO
            = Resources.getString(new ObfuscatedString(new long[]{
            0xA175E3E0B4CCE37FL, 0x9A2E4FA9E233832EL, 0xEDE529E8D84CF0B1L, 0x34BB869CAA79BB93L
    }).toString()); /* => "licenseContent.info" */


    private final KeyStoreParam ftpKeyStoreParam;
    private final int ftpDays;

    /**
     * Creates a new instance of AbstractLicenseParam.
     *
     * @param subject       The licensing subject to be returned by {@link #getSubject()}.
     * @param preferences   The preferences node used to store the license key to be returned by {@link #getPreferences()}.
     * @param keyStoreParam The key store parameters to be returned by {@link #getKeyStoreParam()}.
     * @param cipherParam   The cipher parameters to be returned by {@link #getCipherParam()}.
     */
    protected AbstractLicenseParam(String subject, Preferences preferences, KeyStoreParam keyStoreParam, KeyStoreParam ftpKeyStoreParam, int ftpDays, CipherParam cipherParam) {
        super(subject, preferences, keyStoreParam, cipherParam);
        this.ftpKeyStoreParam = ftpKeyStoreParam;
        this.ftpDays = ftpDays;
    }

    public LicenseContent createFTPLicenseContent() {
        LicenseContent content = new LicenseContent();
        content.setInfo(LICENSE_CONTENT_INFO);
        return content;
    }

}
